<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <cpn @dnum1change="num1change" @dnum2change="num2change" :num1="number1" :num2="number2"></cpn>
    </div>
    <template id="cpn">
        <div>
            <h2>{{num1}}</h2>
            <h3>{{dnum1}}</h3>
            <input type="text" v-model="dnum1">
            <h2>{{num2}}</h2>
            <h3>{{dnum2}}</h3>
            <input type="text" v-model="dnum2">
        </div>
    </template>
    <script src="../vue.js"></script>
    <script>
        const cpn={
            template:'#cpn',
            props:{
                num1:{
                    type:Number
                },
                num2:{
                    type:Number
                }
            },
            data(){
                return{
                    dnum1:this.num1,
                    dnum2:this.num2
                }
            },
            watch: {
                dnum1(newvalue){
                    // console.log(newvalue)
                    this.dnum2=newvalue*100
                    this.$emit('dnum1change',newvalue*1)

                },
                dnum2(newvalue){
                    // console.log(newvalue)
                    this.dnum1=newvalue/100
                    this.$emit('dnum2change',newvalue*1)
                }
            },
        }

        const app=new Vue({
            el:"#app",
            data:{
                number1:1,
                number2:2
            },
            methods: {
                num1change(newvalue){
                    this.number1=newvalue
                },
                num2change(newvalue){
                    this.number2=newvalue
                }
            },
            components:{
                cpn
            }
        })
    </script>
</body>
</html>